package cn.ibobo.lease.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import org.springframework.stereotype.Component;

/**
 * Description: 生成业务单号工具类 <br />
 * Project: meirenhui <br />
 * ClassName: BusinessNumberUtil.java <br />
 * Copyright: Copyright (c) 2017 deshang<br />
 * 
 * @author qzheng
 * @version 1.0 2018年1月2日上午9:08:34
 */
@Component
public class BusinessNumberUtil {

	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
	
	/**
	 * 生成订单号<br>
	 * Generate the order number format such as 20171212181200_176104
	 * @author qzheng
	 * @createDate 2018年1月2日上午9:10:53
	 * @return
	 */
	public static String generateOrderNo() {

		Date date = new Date();
		String orderNo = sdf.format(date) + "_";
		Random random = new Random();
		for (int i = 0; i < 6; i++) {
			orderNo += random.nextInt(10);
		}

		return orderNo;
	}

	/**
	 * 生成流程单号<br>
	 * Generate the process number format such as P20170102181200_176104
	 * @author qzheng
	 * @createDate 2018年1月2日上午9:14:40
	 * @return
	 */
	public static String generateProcessNo() {

		Date date = new Date();
		String orderNo = "P" + sdf.format(date) + "_";
		Random random = new Random();
		for (int i = 0; i < 4; i++) {
			orderNo += random.nextInt(10);
		}

		return orderNo;
	}
}
